<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>发布公告</title>
<link rel="stylesheet" href="<%=request.getContextPath() %>/resource/css/common.css" />
<script type="text/javascript" src="<%=request.getContextPath() %>/resource/js/jquery/jquery-1.8.2.js"></script> 
<script type="text/javascript" src="<%=request.getContextPath() %>/resource/js/jquery/jquery.form.js"></script> 
<script charset="utf-8" src="<%=request.getContextPath()%>/resource/iKindEditor/editor/kindeditor.js"></script>
<script charset="utf-8" src="<%=request.getContextPath()%>/resource/iKindEditor/editor/lang/zh_CN.js"></script>
<link rel="stylesheet" href="<%=request.getContextPath()%>/resource/iKindEditor/editor/plugins/code/prettify.css" />
<link rel="stylesheet" href="<%=request.getContextPath()%>/resource/iKindEditor/editor/themes/default/default.css" />
<script charset="utf-8" src="<%=request.getContextPath()%>/resource/iKindEditor/editor/plugins/code/prettify.js"></script>
<script src="<%=request.getContextPath()%>/resource/js/articleEditor.js"></script>
<script>
function filesubmit() {

    $('#myform').ajaxSubmit({
        dataType:  'json',
        url : '<%=getServletContext().getInitParameter("uploaderURL")%>',
        type: 'POST',
        success:function(res){
			if(res.error == 0) {
				$("#noticePicUrl").val(res.url);
				$("#imgPath").html("<img width='100px;' height='100px;' src="+res.url+">"+"</img>");
			}
			else {
				alert("系统保存文件错误！错误信息：" + res.message);
			}
        }
    });

}

function submitNotice() {
	articleEditor_inputEditor.sync(); // 将编辑框中的内容同步到textarea编辑框中来
	var noticePicUrl = $("#noticePicUrl").val();
	var noticeSummary = articleEditor_inputEditor.text().replace(new RegExp("<\\s*img\\s+([^>]*)>", 'g'), "");
	noticeSummary = noticeSummary.replace(new RegExp("<\\s*embed\\s+([^>]*)>", 'g'), "");
	var summaryTextLength = 60;
	if (noticePicUrl == null || "" === noticePicUrl) {
		summaryTextLength = 180;
	}
	if (noticeSummary.length > summaryTextLength){
		noticeSummary = noticeSummary.substr(0, summaryTextLength - 1) + "...";
	}
	$("#noticeSummary").val(noticeSummary);
	$("#noticeForm").submit();
}

$(function(){
	$("#submitButton").click(submitNotice);
});

</script>
</head>
<body>
<%@ include file="top.jsp" %>
	<div style="width: 1000px;height: 500px;margin: 0 auto;margin-top: 130px;border: 1px solid #C3E99E;">
		<div style="margin: 0 auto;width: 1000px;height: 46px;line-height: 45px;text-align: left;font-size:18px;background:white;">
		<div style="margin-top:2px;width: 900px;height: 42px;border-bottom:1px solid #8CC700;margin-left: 50px;">	
		
		<b>&nbsp;&nbsp;添加公告  </b>
		&nbsp;&nbsp;&nbsp;&nbsp;<font size="2">*号为必填项,如果需要上传图片请先上传图片再写公告内容</font>
		</div>
		
		</div>
		
		<form action="<%=getServletContext().getInitParameter("uploaderURL")%>" method="post" id="myform" name="myform" enctype="multipart/form-data" target="douplaod">
			
			<div style="width: 100%;height: 45px;line-height: 45px;text-align: left;margin-left:80px;">
				<div style="float: left;width: 350px;height: 100%;">
					公告图片：<input type="file" name="file" id="filess" onchange="filesubmit()">
				</div>
				<div id="checkNoticeTitle" style="float: left;width: 240px;height: 100%;font-size: 13px;">
				</div>
				<div style="clear:both"></div>
		</div>
		</form>
		<iframe name="douplaod" style="display:none;">
			
					</iframe>
					
			<div style="width: 100%;height: 100px;line-height: 45px;text-align: left;margin-left:80px;">
				<div id="imgPath" style="float: left;width: 350px;height: 100%;margin-left: 50px;">
					
				</div>
				<div style="clear:both"></div>
		</div>
		<form action="<%=request.getContextPath() %>/notice/admin/addNoticeInfo" method="post" id="noticeForm" >
		<div style="width: 100%;height: 45px;line-height: 45px;text-align: left;margin-left:80px;">
				<div style="float: left;width: 290px;height: 100%;">
					公告标题：<input id="noticeTitle" maxlength="30" name="noticeTitle"  type="text" style="height:25px;width:200px;">&nbsp;&nbsp;*
				</div>
				<div id="checkNoticeTitle" style="float: left;width: 240px;height: 100%;font-size: 13px;">
				</div>
				<div style="clear:both"></div>
		</div>
		
		<div style="width: 100%;height: 45px;line-height: 45px;text-align: left;margin-left:80px;">
				<div style="float: left;width: 350px;height: 100%;">
					公告类型：<input name="noticeType" type="radio" value="SITE" checked="checked">网站公告
						<input name="noticeType" type="radio" value="COMMUNITY">社区公告<span style="margin-left:70px;"></span>
				</div>
		</div>
	
		<div style="width: 100%;height: 45px;line-height: 45px;text-align: left;margin-left:80px;">
				<div style="float: left;width: 100%;height: 100%;">
					<div style="float: left;">公告内容：</div>
					<div style="float: left;">
						<textarea id="inputTextArea" name="noticeContent" style="display: bolck;width:730px; height:200px;"></textarea>
					</div>
					<div style="float: left;">&nbsp;&nbsp;</div>
				</div>
				<div id="checkNoticeContext" style="float: left;width: 240px;height: 100%;font-size: 13px;">
				</div>
				<div style="clear:both"></div>
		</div>
		
		<input name="noticePicUrl" id="noticePicUrl" type="hidden">
		<input name="noticeSummary" id="noticeSummary" type="hidden" value="">
		
		<div style="margin-top: 200px;margin-left: 140px;">
			<input type="button" id="submitButton" class="button_style" value="立即提交">
			<!-- <input type="submit" id="submitButton" class="button_style" value="立即提交"> -->
		</div>
		</form>
	</div>
	<div>
		
	</div>
<%@ include file="foot.jsp" %>
</body>
</html>